import { get_time_normal_to_format } from '../../../../../../../../../../../../../../global/Func/get_cur_format_time';
import { prop_cur_req_time } from '../../../../../../../../../../../Classes/cla_req_cur_headers_info';
import { get_file_path_prefix_cur_user_music } from '../../../../../Func/Set_file/Func/get_file_path_cur_user_music';
import { req_info_music_audio_upload } from '../../../Classes/cla_req_info_upload_music_audio';
import { spacename_audio } from '../../../DataDefine/sourceData';

/**
 * path cur_user /music / audio-->
 *
 * D:/class_laugh_files/user/${cur_user_id}/music/audio/${cur_audio_id}
 */
export function get_file_path_prefix_cur_user_music_cur_audio(
  cur_info: req_info_music_audio_upload
) {
  return `${get_file_path_prefix_cur_user_music(cur_info)}/${spacename_audio}/${
    cur_info.id
  }`;
}

/**
 * name: ${cur_info.id}.${cur_info.ext}
 * 
 * name_time: ${cur_info.id}_${get_time_normal_to_format(
      cur_info[prop_cur_req_time]
    )}.${cur_info.ext}
 */
function get_file_name_audio(cur_info: req_info_music_audio_upload) {
  return {
    file_name: `${cur_info.id}.${cur_info.ext}`,
    file_name_time: `${cur_info.id}_${get_time_normal_to_format(
      cur_info[prop_cur_req_time]
    )}.${cur_info.ext}`,
  };
}

/**
 * path -->
 *
 * D:/class_laugh_files/user/${cur_user_id}/music/audio/${cur_audio_id}/audio.${ext}
 */
export function get_file_path_cur_audio(cur_info: req_info_music_audio_upload) {
  return `${get_file_path_prefix_cur_user_music_cur_audio(cur_info)}/${
    get_file_name_audio(cur_info).file_name
  }`;
}

/**
 * path -->
 *
 * D:/class_laugh_files/user/${cur_user_id}/music/audio/${cur_audio_id}/audio_${dueto_time}.${ext}
 */
export function get_file_path_cur_audio_time(
  cur_info: req_info_music_audio_upload
) {
  return `${get_file_path_prefix_cur_user_music_cur_audio(cur_info)}/${
    get_file_name_audio(cur_info).file_name_time
  }`;
}
